package com.ruoyi.pachong.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.pachong.mapper.HpageDaohangMapper;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.pachong.domain.HpageDaohang;
import com.ruoyi.pachong.service.IHpageDaohangService;

/**
 * 优质导航数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-04-08
 */
@Service
public class HpageDaohangServiceImpl implements IHpageDaohangService 
{
	
	protected static final String daoHangKey = "hp-daohangkey";
	
    @Autowired
    private HpageDaohangMapper hpageDaohangMapper;
    
    @Autowired
    private RedisCache redisCache;
    /**
     * 查询优质导航数据
     * 
     * @param dhId 优质导航数据主键
     * @return 优质导航数据
     */
    @Override
    public HpageDaohang selectHpageDaohangByDhId(Long dhId)
    {
        return hpageDaohangMapper.selectHpageDaohangByDhId(dhId);
    }

    /**
     * 查询优质导航数据列表
     * 
     * @param hpageDaohang 优质导航数据
     * @return 优质导航数据
     */
    @Override
    public List<HpageDaohang> selectHpageDaohangList(HpageDaohang hpageDaohang)
    {
    	
    	List<HpageDaohang> list = redisCache.getCacheList(daoHangKey);
    	
    	 if (StringUtils.isNotNull(list) && StringUtils.isNotEmpty(list)) {
    		 
    	 }else {
    		 list = hpageDaohangMapper.selectHpageDaohangList(hpageDaohang);
    		 redisCache.setCacheList(daoHangKey, list);
    		 redisCache.expire(daoHangKey, 100);
    	 }
    	
        return list;
    }

    /**
     * 新增优质导航数据
     * 
     * @param hpageDaohang 优质导航数据
     * @return 结果
     */
    @Override
    public int insertHpageDaohang(HpageDaohang hpageDaohang)
    {
        return hpageDaohangMapper.insertHpageDaohang(hpageDaohang);
    }

    /**
     * 修改优质导航数据
     * 
     * @param hpageDaohang 优质导航数据
     * @return 结果
     */
    @Override
    public int updateHpageDaohang(HpageDaohang hpageDaohang)
    {
        return hpageDaohangMapper.updateHpageDaohang(hpageDaohang);
    }

    /**
     * 批量删除优质导航数据
     * 
     * @param dhIds 需要删除的优质导航数据主键
     * @return 结果
     */
    @Override
    public int deleteHpageDaohangByDhIds(Long[] dhIds)
    {
        return hpageDaohangMapper.deleteHpageDaohangByDhIds(dhIds);
    }

    /**
     * 删除优质导航数据信息
     * 
     * @param dhId 优质导航数据主键
     * @return 结果
     */
    @Override
    public int deleteHpageDaohangByDhId(Long dhId)
    {
        return hpageDaohangMapper.deleteHpageDaohangByDhId(dhId);
    }
}
